﻿<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		  content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
	<meta http-equiv="Cache-Control" content="no-siteapp"/>
	<!--[if lt IE 9]>
	<script type="text/javascript" src="lib/html5shiv.js"></script>
	<script type="text/javascript" src="lib/respond.min.js"></script>
	<![endif]-->
	<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script>
	<script type="text/javascript" src="../js/commonUtils.js"></script>
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
	<link rel="stylesheet" type="text/css" href="layui/css/layui.css"/>

	<!--[if IE 6]>
	<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
	<script>DD_belatedPNG.fix('*');</script>
	<![endif]-->
	<title>车辆列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 车辆管理 <span
		class="c-gray en">&gt;</span> 车辆列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
											  href="javascript:location.replace(location.href);" title="刷新"><i
		class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">


	<table class="layui-hide" id="demo" lay-filter="demo"></table>
	<div class="mt-20">


	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<!--<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>-->
<link type="text/css" href="layui/css/layui.css"/>
<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/html" id="barDemo">
	<!--<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">支付</a>
</script>
<script type="text/javascript">

    var limitcount = 10;
    var curnum = 1;
    layui.use(['table', 'laypage', 'layer', 'form', 'laydate', 'layedit'], function () {
        var laydate = layui.laydate;
        var form = layui.form;
        var layer = layui.layer;
        var layedit = layui.layedit;
        var laypage = layui.laypage;

        var table = layui.table;
        loadInit();

        function loadInit() {
            table.render({
                elem: '#demo'
                , height: 450
                , url: '/carData/paymentCar' //数据接口
                , method: 'post'
                , where: {
                    type: $("#type").val(),
                    logmin: $("#logmin").val(),
                    logmax: $("#logmax").val(),
                    retrieval: $("#retrieval").val()
                    //请求参数
                }
                , request: {
                    /*修改默认字段*/
                    pageName: 'pageNum'
                    , limitName: 'pageSize'
                }
                , parseData: function (res) { //res 即为原始返回的数据
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.list //解析数据列表
                    };
                }
                , cols: [[ //表头
                    {type: 'checkbox', fixed: 'left'}
                    , {field: 'id', title: 'ID', width: 200, sort: true, totalRowText: '合计：'}
                    , {field: 'type', title: '标题', width: 250, sort: true}
                    , {field: 'type', title: '分类', width: 200, sort: true, totalRow: true}
                    , {field: 'dataFrom', title: '数据来源', width: 200}
                    , {field: 'leaseTime', title: '出租时间', width: 250}
                    , {field: 'returnTime', title: '归还时间', width: 250}
                    , {field: 'totalPrice', title: '需支付(元)', width: 250}
                    , {field: 'number', title: '出租辆数', width: 200}
                    , {fixed: 'right', width: 165, align: 'center', toolbar: '#barDemo'}
                ]]
                , page: true //开启分页
                , done: function (res, curr, count) {
                    laypage.render({
                        elem: 'pageDemo'
                        , count: count
                        , curr: curnum
                        , limit: limitcount
                        , layout: ['page', 'prev', 'next', 'skip', 'count', 'limit']
                        , jump: function (obj, first) {
                            if (!first) {
                                curnum = obj.curr;
                                limitcount = obj.limit;
                            }
                        }
                    })
                }
            });
        }

        $("#submit").on('click', function () {
            loadInit();
        });
        $("#del").on('click', function () {
            deleteData();
        })

        function deleteData() {
            var checkStatus = table.checkStatus("demo")
                , data = checkStatus.data; //获取选中的数据
            if (data.length === 0) {
                layer.msg('请选择一行');
            } else {
                var ids = [];
                for (var i = 0; i < data.length; i++) {
                    ids.push(data[i].id)
                }
                /*console.log(list.toString())
                layer.msg(list.toString());
                for(var j=0;j<list.length;j++){
                    layer.msg(list[j].get("id"));
                    console.log(list[j].get("id"))
                }*/
                serviceRequestSync('/carData/delData',{ids:ids},function (response) {
                    if(response.status == "0000"){
                        loadInit();
                    }

                })

            }

        };

        table.on('tool(demo)',function (obj) {
            var data = obj.data //获得当前行数据
            var layEvent = obj.event;
            if(layEvent=='del'){
                layer.confirm('确定支付吗？', function (index) {
                    layer.close(index);
                    serviceSyncRequest("/carData/pay", {
                        id: data.id,
                        leaseNum:data.number,
                        flag: "Y"
                    }, function (data) {
                        if(data.Status=="0000"){
                            obj.del(); //删除对应行（tr）的DOM结构
                            layer.msg('支付成功!!!', {icon: 1});
                            loadInit()
						}

                    })

                })


                /*layer.prompt({title: '出租数量，并确认', formType: 0}, function (pass, index) {
                    alert(pass)
                    alert(data.id)
                    alert(data.number)
                    serviceRequestSync('/carData/updateCar',{num:pass,idX:data.id,numCar:data.number},function (response) {
                        layer.close(index);
                        layer.msg(response.ReDes);
                        loadInit();
                    })
                });*/
            }

        })






    });


</script>
</body>
</html>